import requests
import json
import pandas as pd

excel_name = "57-瞿汝强学习档案20230629105606(1).xlsx"
studentCode = "d026013d74cc4aaab900ffe15642736a"

classCode  = "56073687691248888873b5195c21dbbd"
url = "http://118.24.238.115:8080/gdjt-manager-v2/class/getOnlineLearningRate?page=1&limit=90&classCode="+classCode+"&studentCode="+studentCode+"&studyStatus=&resName=&_=1690940015484"
head = {"Cookie": "SHRIOSESSIONID=c61cf2fb-7fd2-4866-895b-03689f0e30b7"}

print("开始核对：" + excel_name + " -- " + studentCode)
json_str = requests.get(url ,headers=head).content
json_map = json.loads(json_str)
json_arr = json_map["data"]  
time_arr = []
for item in json_arr:
    time = item["videoStarTime"]+"-"+item["videoEndTime"]
    time_arr.append(time.replace(" ",""))


data = pd.read_excel(io=excel_name,header=11,usecols="H,I")
excel_arr = []
for i in range(0, len(data)):
    time = str(data.iloc[i][0])+"-"+str(data.iloc[i][1])
    if(time.find("nan")<0) :
        excel_arr.append(time.replace("\n",""))

size = len(time_arr)
print(len(time_arr))
print(len(excel_arr))

for i in range(0,size):
    if(time_arr[i] != excel_arr[i]):
        print(excel_name + "第" + str(i+1) + "行错误！网页时间：" + time_arr[i] + " -- excel时间：" + excel_arr[i])
print("核对完成！")